import * as lang from "./../../config/lang";

export default {
  namespaced: true,
  state: {
    userLang: {
      ...lang.defaultLang,
    },
  },
  getters: {
    getLang: (state) => (key) => {
      return state.userLang[key];
    },
  },
  mutations: {
    // 重置语言项
    resetLang(state, langs) {
      state.userLang = {
        ...state.userLang,
        ...langs,
      };
    },
    // 设置单个语言项
    setLang(state, { key, value }) {
      state.userLang[key] = value;
    },
  },
};
